package com.atguigu.yygh.common.exception;

import com.atguigu.yygh.common.result.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author kabuda
 * @create 2023-02-20 11:17
 */
@ControllerAdvice(annotations = {Controller.class, RestController.class})
@ResponseBody
public class GlobalExceptionHandler {
    @ExceptionHandler(YyghException.class)
    public Result YyghExceptionHandler(YyghException e){
        e.printStackTrace();
        return Result.fail();
    }

    @ExceptionHandler(Exception.class)
    public Result ExceptionHandler(Exception e){
        e.printStackTrace();
        return Result.fail(e.getMessage());
    }
}
